<template>
  <div class="app-container">
    <el-form  ref="form" :model="form" label-width="100px" @submit.native.prevent>
      <el-form-item label="业务介绍">
        <el-input
          type="textarea"
          :autosize="{ minRows: 4, maxRows: 10}"
          placeholder="请输入业务介绍"
          v-model="businessDescription"
          style="width: 400px">
        </el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submit">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
    // todo 接口： /web/company/upgradeBaseInfo  
    export default {
      name: "Business",
      data(){
        return{
          businessDescription: ''
        }
      },
      methods: {
        getCompanyInfo () {
          this.$fetch(this.$api.getCompanyInfo).then(res => { // 获取企业信息
            this.businessDescription = res.data.businessDescription
          })
        },
        submit () {
          if (this.businessDescription.length === 0) {
            this.$message.error('请输入业务介绍')
          } else {
            this.$fetch(this.$api.updateCompanyInfo, {
              businessDescription: this.businessDescription
            }).then(res => {
              if (res.code === 0 && res.msg === 'OK') {
                this.$message.success('业务介绍更新成功')
                this.getCompanyInfo()
              } else {
                this.$message.error('业务介绍更新失败')
              }
            })
          }
        }
      },
      created () {
        this.getCompanyInfo()
      }
    }
</script>

<style scoped>

</style>
